//
//  SettingViewController.m
//  CarLifes
//
//  Created by yu on 2017/8/21.
//  Copyright © 2017年 jpas. All rights reserved.
//

#import "SettingViewController.h"
#import "TabBarController.h"
#import "UIView+TransitionAnimation.h"
#import "ModifyPsdViewController.h"

@interface SettingViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"设置";
    [self.view addSubview:self.tableView];
    self.tableView.sd_layout.spaceToSuperView(UIEdgeInsetsZero);
}

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.backgroundColor = [UIColor groupTableViewBackgroundColor];

    }
    return _tableView;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 45;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 8;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *cellIdentifier = @"cellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.textColor = kTextBlackColor;
        cell.textLabel.font = SYSTEM_FONT(15);
        
        if (indexPath.section == 0) {
            cell.textLabel.text = @"修改密码";
        }
        else if (indexPath.section == 1)
        {
            cell.textLabel.text = @"退出车架号登录";
        }
        UIImageView *arrowImg = [[UIImageView alloc] initWithImage:IMAGE_NAMED(@"arrow_right")];
        cell.accessoryView = arrowImg;
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        ModifyPsdViewController *modifyPassword = [[ModifyPsdViewController alloc] init];
//        modifyPassword.type = @1;
        [self.navigationController pushViewController:modifyPassword animated:YES];
    }
    else if (indexPath.section == 1)
    {
        TabBarController *tab = [[TabBarController alloc] init];
        [KEY_WINDOW addTransitionAnimationWithDuration:0.5f type:TransitionPageUnCurl subType:FROM_BOTTOM];
        KEY_WINDOW.rootViewController = tab;
    }
}

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
    view.tintColor = [UIColor clearColor];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
